<?php
use common\service\StaticService;
use common\service\GlobalUrlService;
use backend\assets\AdminAsset;

StaticService::includeAppJsStatic(GlobalUrlService::buildStaticUrl('/backend/content/article.js'),AdminAsset::class);
?>

<form class="layui-form">
    <div class="layui-card">
        <div class="layui-card-header">文章管理</div>
        <div class="layui-card-body">
            <div class="layui-form-item">
                <label class="layui-form-label"></label>
                <div class="layui-inline">
                    <input type="text"  name="title" class="layui-input" value="<?= $title;?>" placeholder="文章标题"/>
                </div>
                <div class="layui-inline">
                    <input type="submit" class="layui-btn layui-btn-primary" value="搜索"/>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"></label>
                <a class="layui-btn" href="<?= GlobalUrlService::buildAdminUrl('content/add')?>">添加文章</a>
            </div>

            <div class="layui-form-item">
                <table id="content"></table>
            </div>

            <!-- <div class="layui-form-item">
                <a class="layui-btn layui-btn-primary" onclick="window.history.go(-1);">返回</a>
            </div> -->
        </div>
    </div>
</form>
<script type="text/html" id="operation">
    <a class="layui-btn layui-btn-xs" lay-event="lookup">查看</a>
    <a class="layui-btn layui-btn-xs" lay-event="modify">修改</a>
    <a class="layui-btn layui-btn-xs" lay-event="delate">删除</a>
</script>

<span class="tools">
            <form method="get" action="<?php GlobalUrlService::buildStaticUrl('content/content') ?>" class="search">
            <input type="text" id="title" name="title" value="<?= $title; ?>" placeholder="文章标题" />
           <input type="submit" id="search" value="搜索" style="margin-bottom:10px;" />
        </form>
         </span>
<div class="widget">
    <div class="widget-title">
        <h4><i class="icon-cogs"></i>文章管理</h4>
        <a href="<?= GlobalUrlService::buildAdminUrl('content/add')?>" class="text-center blue-long">添加文章</a>
    </div>
    <div class="widget-body" style="display: block;">
        <table class="table table-striped table-bordered table-advance table-hover">
            <thead>
            <tr>
                <th><i class="icon-briefcase"></i> 编号</th>
                <th class="hidden-phone"></i>文章标题</th>
                <th>文章类型</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <?php  foreach ($datas as $key=>$data):?>
                <tr >
                    <td ><?= $key+1?>  </td>
                    <td> <?= $data['title']?></td>
                    <?php if ($data['type']==1){ ?>
                    <td>关于我们</td>
                   <?php } ?>
                    <?php if ($data['type']==2){ ?>
                        <td>常见问题</td>
                    <?php } ?>
                    <?php if ($data['type']==3){ ?>
                        <td>免责声明</td>
                    <?php } ?>
                    <td>
                        <a href="<?= GlobalUrlService::buildAdminUrl('content/select',['id'=>$data['id']])?>" class="btn mini purple" ><i class="icon-fire"></i>  查看 </a>
                        <a href="<?= GlobalUrlService::buildAdminUrl('content/update',['id'=>$data['id']])?>" class="btn mini purple"><i class="icon-edit"></i>  修改 </a>
                        <a class="btn mini black" status="<?=$data['id']?>"><i class="icon-trash"></i> 删除</a>
                    </td>
                </tr>
            <?php endforeach;?>
            </tbody>
        </table>
    </div>
</div>